﻿using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Poplar.Passport.DbContexts;
using Poplar.Passport.IRepositories;
using Poplar.Passport.Models;

namespace Poplar.Passport.Repositories
{
    public class UserRepository : IUserRepository
    {
        private readonly PassportDbContext _dbContext;

        public UserRepository(PassportDbContext dbContext)
        {
            this._dbContext = dbContext;
        }

        public async Task<User> GetUser(string userName, string password)
        {
            return await this._dbContext.Users.FirstOrDefaultAsync(item =>
                item.UserName == userName && item.Password == password && !item.IsDeleted);
        }
    }
}
